package com.dyh.quickdemo.bizDemo.Eigenvector;

import com.google.common.collect.Lists;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;

/*
@Author=Joey Wheeler
@Date=2021/2/24 11:09
*/
public class M {

    public static void main(String[] args) {
        Map<String, Consumer<Student>> executors =
                new HashMap<>();
        executors.put("M1",e-> System.out.println("参军"));
        executors.put("M0",e-> System.out.println("后备军"));




        List<Student> students = Lists.newArrayList(
                new Student(1,'M'),
        new Student(11,'M'),
        new Student(21,'M')
        );

        for (Student student : students) {
            Optional.ofNullable(executors.get(student.normalize()))
                    .orElse(e-> System.out.println("回去"))
            .accept(student);
        }
    }
}
